<template>
  <div>
    <!-- <p>
      历史贷款审批记录-支持在历史贷款审核页面查询客户的历史面签信息。点击“审核历史”进入审核历史页面
    </p> -->
    <LoanhistoryTab
      v-if="showloanhistoryTab"
      :option="optionList"
      :tableData="tableData"
      @faceuserinfo="faceuserinfo"
      @handleChange="handleChange"
      @getInfodata="getInfodata"
    />
    <Loanhistorylist
      v-if="showloanhistorylist"
      :tableData="receiveInfo"
      @receive="receive"
      @answerhistory="answerhistory"
      @videoInfo="videoInfo"
    />
    <Loanhistoryvideo
      v-if="showloanhistoryvideo"
      :tableData="receiveInfo"
      @gobackretrieve="gobackretrieve"
    />
    <Loadnhistoryanswer
      v-if="showloanhistoryanswer"
      :tableData="receiveInfo"
      @gobackanswer="gobackanswer"
    />
  </div>
</template>

<script>
import LoanhistoryTab from "@/views/loanhistory/loanhistoryTab.vue";
import Loanhistorylist from "@/views/loanhistory/loanhistorylist.vue";
import Loanhistoryvideo from "@/views/loanhistory/loanhistoryvideo.vue";
import Loadnhistoryanswer from "@/views/loanhistory/loadnhistoryanswer.vue";
import { queryInfoCMIS200028 } from "@/api/hubeixiaojin/queryInfo";
export default {
  components: {
    LoanhistoryTab,
    Loanhistorylist,
    Loanhistoryvideo,
    Loadnhistoryanswer
  },

  data() {
    // 表单身份证
    var idcardReg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
    var validatePhone = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("证件号不能为空!!"));
      }
      if (!idcardReg.test(value)) {
        callback(new Error("请输入正确的证件号码！"));
      } else {
        callback();
      }
    };
    return {
      showloanhistoryTab: true,
      showloanhistorylist: false,
      showloanhistoryvideo: false,
      showloanhistoryanswer: false,

      //客户信息
      tableData: {
        list: [],
        paging: true,
        page: {
          total: "",
          pageSize: 10,
          page: 1
        }
      },
      //表头
      optionList: [
        {
          label: "客户申请编号",
          prop: "applCde"
        },
        {
          label: "客户证件号码",
          prop: "idNo"
        },
        {
          label: "客户名称",
          prop: "custName"
        },
        {
          label: "贷款申请金额",
          prop: "applyAmt"
        },
        {
          label: "贷款期限",
          prop: "applyTnr"
        },
        {
          label: "门店",
          prop: "cooprName"
        },
        {
          label: "申请类型", //没找到
          prop: "wfiIntoPiecesMarked"
        },
        {
          label: "进件通道",
          prop: "docChannel"
        }, 
        {
          label: "申请日期",
          prop: "applyDt"
        },
        {
          label: "持续时长/进件时长",
          prop: "nodestarttime"
        },
        {
          label: "申请状态",
          prop: "wfiStatus"
        },
        {
          label: "是否挂起",
          prop: "suspendInd"
        },
        {
          label: "办理人",
          prop: "agentName"
        },
        {
          label: "调单指定人",
          prop: "dispatchingPerson"
        },
        {
          label: "营销中心",
          prop: "marketingCenter"
        }
      ],
      receiveInfo: {},
      formInline: {
        custName: "",
        idNo: "",
        applCde: ""
      },
      // agentInfo: {
      //   //当前座席名字和id
      //   dispatchingPerson: Constants.Agent.agentName,
      //   dispatchingId: Constants.Agent.agentId,
      //   //目标座席和id
      //   agentId: "",
      //   agentName: "",
      //   //座席行政组
      //   deptGroupName: Constants.Agent.deptGroupName,
      //   //行政组code
      //   deptGroupCode: Constants.Agent.deptGroupCode,
      //   //access_token
      //   access_token: Constants.Agent.access_token,
      //   //tenantId
      //   tenantId: Constants.Agent.tenantId,
      //   //orgCode
      //   orgCode: Constants.Agent.orgCode
      // } //调单用到的座席信息
      agentInfo: {}
    };
  },
  mounted() {
    const sessionStr = sessionStorage.getItem("userInfo");
    const agentUser = JSON.parse(sessionStr);
    this.agentInfo = agentUser.content;
    this.getInfo();
  },
  methods: {
    getInfo() {
      var params = {
        page: this.tableData.page.page, //翻页当前页码
        pageSize: this.tableData.page.pageSize, //翻页一次显示数量
        sortCol: "id",
        condition: {
          status: "11,12",
          // pushStatus: true,
          custName: this.formInline.custName, //客户姓名
          idNo: this.formInline.idNo, //身份证
          applCde: this.formInline.applCde //申请编号
        } //申请状态
      };

      queryInfoCMIS200028(params, this.agentInfo)
        .then(res => {
          if (res.data.retCode === 200) {
            this.tableData.list = res.data.data.listData; //数据
            this.tableData.page.total = res.data.data.totalCount; //总笔数
          } else {
            // console.log(res.msg);
            window.globalUiKit.notify("提示", "未查询到历史记录", "info");
          }
        })
        .catch(err => {
          console.log(err);
        });
    },

    getInfodata(val) {
      console.log("历史记录查询", val);
      this.formInline = val;
      this.tableData.page.page = 1;
      this.getInfo();
    },

    answerhistory() {
      console.log("切换到答题历史");
      this.showloanhistoryTab = false;
      this.showloanhistorylist = false;
      this.showloanhistoryvideo = false;
      this.showloanhistoryanswer = true;
    },
    gobackanswer() {
      console.log("答题历史页面返回");
      this.showloanhistoryanswer = false;
      this.showloanhistoryvideo = false;
      this.showloanhistoryTab = false;
      this.showloanhistorylist = true;
    },
    videoInfo() {
      console.log("切换到视频调阅");
      this.showloanhistoryvideo = true;
      this.showloanhistoryTab = false;
      this.showloanhistorylist = false;
    },
    gobackretrieve() {
      console.log("视频调阅页面返回");
      this.showloanhistoryvideo = false;
      this.showloanhistoryTab = false;
      this.showloanhistorylist = true;
    },
    faceuserinfo(val) {
      console.log("接收到切换审核历史消息", val);
      this.receiveInfo = val[0];
      this.showloanhistoryTab = false;
      this.showloanhistorylist = true;
    },
    adjustmentInfo() {
      this.showadjustorder = false;
      console.log("调单信息", this.form3);
    },

    perReset() {
      console.log("重置");

      this.formInline = {
        custName: "",
        idNo: "",
        applCde: ""
      };
    },
    adjustorder(val) {
      //展开弹窗，下拉框选项
      //在这里获取数据后展开或者页面初始化获取，这里直接展开

      this.showadjustorder = true;
    },
    receive() {
      //返回首页
      this.showloanhistoryTab = true;
      this.showloanhistorylist = false;
    },
    receive2(val) {
      this.receiveInfo = val;
    },
    handleChange(newPage) {
      this.tableData.page.page = newPage;
      this.getInfo();
    }
  }
};
</script>

<style>
.form-inline {
  /* display: flex; */
  /* justify-content: space-between; */
  /* margin-bottom: 20px; */
}
.Search {
  width: 100%;
  text-align: center;
}
.AdjustInput {
  display: flex;
  justify-content: end;
}
</style>
